/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foundation;

import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

/**
 *
 * @author Quirino
 */
public class FUtility {
    
    public static void printListFromXML(XMLOutputter outp, List lis) throws IOException{
        System.out.println("\n");
        Format f= Format.getPrettyFormat();
        outp.setFormat(f);
        outp.output(lis, System.out);
        System.out.println("\n");
    }
    
    public static void printElementFromXML(XMLOutputter outp, Element el) throws IOException{
        System.out.println("\n");
        Format f= Format.getPrettyFormat();
        outp.setFormat(f);
        outp.output(el, System.out);
        System.out.println("\n");
    }
    
    public static Date getDateByXML(String dataXML){
        
        DateFormat formatter ; 
        Date date=null;
        formatter= new SimpleDateFormat("yyyy-MM-dd");
        try {
            date= (Date) formatter.parse(dataXML);
        } catch (ParseException ex) {
            Logger.getLogger(FUtenti.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return date;
        
    }
    
}
